import requests

"""
定义函数，获取登录成功的领导，组织请求头
"""
from api.jiuchao_login_api import JCLoginApi


def get_header():
    # req_data = {"mobile": "19811796705", "password": "jxz123456!@#", "category": "0"}
    # resp = JCLoginApi.login(req_data)
    # result = resp.json()
    # # 从字典里先拿data，再拿accessToken
    # data = result.get("data")  # 先获取data部分
    # access_token = data.get("accessToken")  # 再从data里拿token
    # header = {"Authorization": access_token}
    # return header
    resp = requests.post(url="http://116.62.53.189:48080/admin-api/system/auth/login",
                         headers={"Content-type": "application/json",
                                  "Authorization": "Bearer 876fa56a7f8f4c9f9f6a49b1afcffab0", "tenant-id": "1"},
                         json={"tenantName": "芋道源码", "username": "JcAdmin", "password": "Jc666!", "rememberMe": False})
    result = resp.json()
    data = result.get("data")
    header = {"Authorization": data.get("accessToken")}
    return header


if __name__ == '__main__':
    res = get_header()
    print(res)
